<template>
  <div class="category-list">
    <div class="list-holder" v-for="item1 in $store.state.home.newCategoryList" :key="item1.id">
        <p class="title">{{item1.name}}好物</p>
        <ul class="list">
            <li class="item" v-for="item2 in item1.goodsList" :key="item2.id" @click="toGoods(item2.id)">
                <img :src="item2.list_pic_url" alt="">
                <p class="name">{{item2.name}}</p>
                <p class="price">￥ {{item2.retail_price}}</p>
            </li>
            <li class="item" @click="toCategory(item1.id)">
                <p class="last-title">{{item1.name}}好物</p>
                <img class="last-img" src="../../assets/images/rightbig.png" alt="">
            </li>
        </ul>
    </div>
  </div>
</template>

<script>
export default {
    methods: {
        toGoods(id){
            this.$router.push({path:'/pages/goods/goods',query:{id}});
        },
        toCategory(id){
            this.$router.push({path:'/pages/category/category',query:{id}})
        }
    },
};
</script>

<style lang="scss">
    .category-list{
        .title{
            text-align: center;
            padding: 12px 0;
        }

        .list{
            display: flex;
            width: 100%;
            flex-wrap: wrap;
            .item{
                margin: auto;
                margin-bottom: 5px;
                width: 48%;
                height: 210px;
                background-color: #fff;
                .name{
                    margin-left: 10px;
                    text-overflow: ellipsis;
                    overflow: hidden;
                    white-space: nowrap;
                }
                .price{
                    margin-left: 10px;
                    margin-top: 16px;
                    color: #9c3232;
                }
                img{
                    display: block;
                    margin: 0 auto;
                    width: 150px;
                    height: 150px;
                }
                .last-title{
                    margin-top: 40px;
                    font-size: 16px;
                    text-align: center;
                }
                .last-img{
                    margin-top: 40px;
                    width: 35px;
                    height: 35px;
                }
            }
        }
    }
</style>